/**
 * 
 */
package com.dd.keel.core.database.jta;

import javax.sql.XADataSource;

import org.enhydra.jdbc.pool.StandardXAPoolDataSource;
import org.enhydra.jdbc.standard.StandardXADataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
 * XA Pool Datasource
 * 增加密码解密
 * @author lizheng
 *
 */
public class StandardXAPoolDataSourceEx extends StandardXAPoolDataSource {

	private static Logger logger = LoggerFactory.getLogger(StandardXAPoolDataSourceEx.class);
	/**
	 * 
	 */
	private static final long serialVersionUID = -3134456061962744132L;

	/**
	 * 
	 */
	public StandardXAPoolDataSourceEx() {
	}

	/**
	 * @param initSize
	 */
	public StandardXAPoolDataSourceEx(int initSize) {
		super(initSize);
	}

	/**
	 * @param ds
	 */
	public StandardXAPoolDataSourceEx(StandardXADataSource ds) {
		super(ds);
	}

	/**
	 * @param ds
	 * @param initSize
	 */
	public StandardXAPoolDataSourceEx(StandardXADataSource ds, int initSize) {
		super(ds, initSize);
	}

	/* (non-Javadoc)
	 * @see org.enhydra.jdbc.core.CoreDataSource#setPassword(java.lang.String)
	 */
	@Override
	public void setPassword(String password) {
		super.setPassword(password);
	}

	/* (non-Javadoc)
	 * @see org.enhydra.jdbc.pool.StandardXAPoolDataSource#setDataSource(javax.sql.XADataSource)
	 */
	@Override
	public void setDataSource(XADataSource dataSource) {
		super.setDataSource(dataSource);
		if (getDataSource() != null && getDataSource() instanceof com.dd.keel.core.database.jta.StandardXADataSourceEx) {
			com.dd.keel.core.database.jta.StandardXADataSourceEx dsEx = (com.dd.keel.core.database.jta.StandardXADataSourceEx)getDataSource();
			this.setUser(dsEx.getUser());
			super.setPassword(dsEx.getPassword());
		}
	}
}
